Bug 596019 - No accessors for GtkDialog buttons
authorJavier Jardón <javierjc1982@gmail.com>
Wed, 23 Sep 2009 14:53:55 +0000 (16:53 +0200)
committerJavier Jardón <javierjc1982@gmail.com>
Mon, 12 Oct 2009 15:20:02 +0000 (17:20 +0200)
Add API for GtkDialog to return widgets by response ID.
Added gtk_dialog_get_widget_for_response() to access to all kinds
of buttons with all kinds of responses.

gtk/gtk.symbols
gtk/gtkdialog.c
gtk/gtkdialog.h

index 841780b847cdf0dff573647b141091058e5f2fba..81311df9d475f8d57ac7c4723c3a137bb71e3e7b 100644 (file)
@@ -1126,6 +1126,7 @@ gtk_dialog_add_buttons G_GNUC_NULL_TERMINATED
 gtk_dialog_get_action_area
 gtk_dialog_get_content_area
 gtk_dialog_get_has_separator
+gtk_dialog_get_widget_for_response
 gtk_dialog_get_response_for_widget
 gtk_dialog_get_type G_GNUC_CONST
 gtk_dialog_new
index d4633068442682df2f96d4858b123062b2f7f3e1..eb25f5224bbe5c3d693414d3763f8321eee49514 100644 (file)
@@ -1120,6 +1120,49 @@ _gtk_dialog_set_ignore_separator (GtkDialog *dialog,
   priv->ignore_separator = ignore_separator;
 }
 
+/**
+ * gtk_dialog_get_widget_for_response:
+ * @dialog: a #GtkDialog
+ * @response_id: the response ID used by the @dialog widget
+ *
+ * Gets the widget button that uses the given response ID in the action area
+ * of a dialog.
+ *
+ * Returns: the @widget button that uses the given @response_id, or %NULL.
+ *
+ * Since: 2.20
+ */
+GtkWidget*
+gtk_dialog_get_widget_for_response (GtkDialog *dialog,
+                                   gint       response_id)
+{
+  GList *children;
+  GList *tmp_list;
+
+  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
+
+  children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+  tmp_list = children;
+  while (tmp_list != NULL)
+    {
+      GtkWidget *widget = tmp_list->data;
+      ResponseData *rd = get_response_data (widget, FALSE);
+
+      if (rd && rd->response_id == response_id)
+        {
+          g_list_free (children);
+          return widget;
+        }
+
+      tmp_list = g_list_next (tmp_list);
+    }
+
+  g_list_free (children);
+
+  return NULL;
+}
+
 /**
  * gtk_dialog_get_response_for_widget:
  * @dialog: a #GtkDialog
index 69d2c0049fe261c65c56fece9db228084725239b..18a18961c884594024a9696d7750ea9d8bbead19 100644 (file)
@@ -148,6 +148,8 @@ void gtk_dialog_set_response_sensitive (GtkDialog *dialog,
                                         gboolean   setting);
 void gtk_dialog_set_default_response   (GtkDialog *dialog,
                                         gint       response_id);
+GtkWidget* gtk_dialog_get_widget_for_response (GtkDialog *dialog,
+                                               gint       response_id);
 gint gtk_dialog_get_response_for_widget (GtkDialog *dialog,
                                         GtkWidget *widget);